const redis = require('redis')
const client = redis.createClient( 6379, '8.142.104.99', {})
const obj = { 
    get redisCli() {
        return this._client
    },
    set redisCli(c) {
        this._client = c 
    }
}
obj.redisCli = client 
client.auth('1qaz@WSX12345', () => {
    console.log('redis 通过认证')
})

client.on('error', (err) => {
    console.log('redis error: ', err)
    console.log('err.code: ', err.code)
    if(err.code == 'ECONNRESET') {
        console.log('ECONNRESET.............reconnect...')
        obj.client = redis.createClient( 6379, '8.142.104.99', {})
        client.auth('1qaz@WSX12345', () => {
            console.log('redis 通过认证')
        })
    }
})

module.exports = obj  